<?php

/*
	The right sidebar is build accordingly to the side which is called. For that the Conditional Tags are checked:
	            is_home()
	            is_page()
	            is_single()
	            is_archive()
	            is_404()
	            is_search()
*/

global  $comments;

rewind_posts();

if ( is_home() )
{
	echo "\n" . '<div id="sidebar_right">' . "\n\n";

	echo '  <ul>' . "\n";
	echo '    <li>' . "\n";
	echo '      <h2>' . __('Hot News', 'german_newspaper') . '</h2>' . "\n";
	echo '			<ul>' . "\n";

	wp_get_archives('type=postbypost&limit=5');

	echo '			</ul>' . "\n";
	echo '		</li>' . "\n";
	echo '  </ul>' . "\n";

	$counter_sidebar_r = 1;
	while ( have_posts() )
	{
		the_post();

		if ( $counter_sidebar_r > $main AND $counter_sidebar_r <=  3  )
		{
		  echo '  <div class="post" id="post-' . get_the_ID() . '">' . "\n";
			echo '    <h2>' . the_title( '', '', false) . '</h2>' . "\n";

			the_excerpt();
			
			echo '    <p><a href="' . apply_filters('the_permalink', get_permalink()) . '" rel="bookmark" title="Permalink: ' . the_title( '', '', false) . '">' . "\n";
			echo '    <em>' . __('More on page ', 'german_newspaper') . $post->ID . '</em></a></p>' . "\n";
			echo '  </div>' . "\n\n";
		}
		$counter_sidebar_r++;
	}

	echo "\n" . '<ul>' . "\n";
	
	/* Widgetized sidebar, if you have the plugin installed. */
	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right_Menu') )
	{
	}

	echo '</ul>' . "\n" . '</div>' . "\n\n";
}
   


if ( is_search() )
{
	echo '<div id="sidebar_right">' . "\n\n";
	echo '  <div class="information">' . "\n";
	echo '  <p>' . __('You have searched the ', 'german_newspaper') . '<a href="' . get_bloginfo('url') . '/">' . get_bloginfo('name') . '</a> ' . __('weblog archives for ', 'german_newspaper') . ' <strong>';
	the_search_query();

	echo '</strong>.</p>' . "\n";
	echo '</div>' . "\n\n";
	
/*
	//  list search results
	if ( have_posts() )
	{
	  echo '  <ul>' . "\n";

		while ( have_posts() )
		{
			the_post();

			echo '<li>' . "\n";
			echo '<p><a href="' . apply_filters('the_permalink', get_permalink()) . '" rel="bookmark" title="';
			printf(__('Permanent Link to %s', 'german_newspaper'), the_title_attribute('echo=0'));

			echo '">' . the_title( '', '', false) . '</a></p>' . "\n";
			echo '<small>';
			the_time(__('l, F jS, Y', 'german_newspaper'));
			echo '</small>' . "\n";
			echo '<p class="postmetadata">';
			the_tags(__('Tags: ', 'german_newspaper'), ', ', '<br />');
			echo ' ';
			printf(__('Posted in %s', 'german_newspaper'), get_the_category_list(', '));
			echo '</p>' . "\n" . '</li>' . "\n";
		}

		echo '</li>' . "\n";
		echo '</ul>' . "\n";
	}
*/
	
	echo '<ul>' . "\n";
	echo '  <li>' . "\n";
	echo '    <h2>' . __('Hot News', 'german_newspaper') . '</h2>' . "\n";
	echo '    <ul>' . "\n";
	
	wp_get_archives('type=postbypost&limit=5');
	
	echo '    </ul>' . "\n";
	echo '	</li>' . "\n";
	echo '</ul>' . "\n";
	echo '<ul>' . "\n";

	/* Widgetized sidebar, if you have the plugin installed. */
	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right_Menu') )
	{
	}

	echo '</ul>' . "\n";
	echo '</div>' . "\n";
}



if ( is_single() )
{
	echo '<div id="sidebar_right">' . "\n\n";

	if ( $comments )
	{
		echo '  <h2>' . __('Comments') . '</h2>' . "\n";
		echo '<div class="information">' . "\n";
		echo '  <p>' . __('The following comments are given so far:', 'german_newspaper') . '</p>' . "\n";

		foreach ( $comments as $comment )
		{
		  echo '  <li ' . $oddcomment . 'id="comment-' . get_comment_ID() . '">';
			printf(__('From <cite>%s</cite> on: ', 'german_newspaper'), get_comment_author_link());

   		if ( $comment->comment_approved == '0' )
			{
				echo '<em>' . __('Your comment is awaiting moderation.', 'german_newspaper') . '</em>' . "\n";
			}
			
			echo '<small class="commentmetadata"><a href="#comment-' . get_comment_ID() . '" title="">';
			printf(__('%1$s at %2$s', 'german_newspaper'), get_comment_date(__('F jS, Y', 'german_newspaper')), get_comment_time());
			echo '</a></small>' . "\n";
			echo '  </li>' . "\n";

			/* Changes every other comment to a different class */
			$oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';
		}

		echo '</div>' . "\n\n";
	}
	else
	{
		echo '  <h2>' . __('Comments') . '</h2>' . "\n";
		echo '<div class="information">' . "\n";
		echo '  <p>' . __('No comments so far !', 'german_newspaper') . '</p>' . "\n";
		echo '</div>' . "\n\n";
	}

	echo '<ul>' . "\n";
	
	/* Widgetized sidebar, if you have the plugin installed. */
	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right_Menu') )
	{
	}

	echo '</ul>' . "\n";
	echo '</div>' . "\n\n";
}



if ( is_404() )
{
	echo '<div id="sidebar_right">' . "\n";
	echo '  <ul>' . "\n";

  /* Widgetized sidebar, if you have the plugin installed. */
  if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right_Menu') )
	{
	}

	echo '  </ul>' . "\n";
	echo '</div>' . "\n\n";
}



if ( is_page() )
{
	echo '<div id="sidebar_right">' . "\n";
	echo '  <ul>' . "\n";
	echo '    <li>' . "\n";
	echo '      <h2>' . __('Hot News', 'german_newspaper') . '</h2>' . "\n";
	echo '			<ul>' . "\n";

	wp_get_archives('type=postbypost&limit=5');
	
	echo '			</ul>' . "\n";
	echo '		</li>' . "\n";
	echo '  </ul>' . "\n";
	echo '	<ul>' ."\n";
	
	/* Widgetized sidebar, if you have the plugin installed. */
	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right_Menu') )
	{
	}

	echo '  </ul>' . "\n";
	echo '</div>' . "\n\n";
}




if ( is_archive() )
{
	echo "\n" . '<div id="sidebar_right">' . "\n\n";

	if ( have_posts() )
	{
	  echo '  <ul>' . "\n";
	  echo '	  <li>' . "\n";

		$post = $posts[0]; // Hack. Set $post so that the_date() works.

		/* If this is a category archive */
		if ( is_category() )
		{
		  echo '<h3>';
			printf(__('Archive for the &#8216;%s&#8217; Category', 'german_newspaper'), single_cat_title('', false));
			echo '</h3>' . "\n";
		}
		/* If this is a tag archive */
		elseif( is_tag() )
		{
		  echo '<h3>';
			printf(__('Posts Tagged &#8216;%s&#8217;', 'german_newspaper'), single_tag_title('', false) );
			echo '</h3>' . "\n";
		}
		/* If this is a daily archive */
		elseif ( is_day() )
		{
		  echo '<h3>';
			printf(_c('Archive for %s|Daily archive page', 'german_newspaper'), get_the_time(__('F jS, Y', 'german_newspaper')));
			echo '</h3>' . "\n";
		}
		/* If this is a monthly archive */
		elseif ( is_month() )
		{
		  echo '<h3>';
			printf(_c('Archive for %s|Monthly archive page', 'german_newspaper'), get_the_time(__('F, Y', 'german_newspaper')));
			echo '</h3>' . "\n";
		}
		/* If this is a yearly archive */
		elseif ( is_year() )
		{
		  echo '<h3>';
			printf(_c('Archive for %s|Yearly archive page', 'german_newspaper'), get_the_time(__('Y', 'german_newspaper')));
			echo '</h3>' . "\n";
		}
		/* If this is an author archive */
		elseif ( is_author() )
		{
		  echo '<h3>' . __('Author Archive', 'german_newspaper') . '</h3>' . "\n";
		}
		/* If this is a paged archive */
		elseif ( isset($_GET['paged']) && !empty($_GET['paged']) )
		{
		  echo '<h3>' . __('Blog Archives', 'german_newspaper') . '</h3>' . "\n";
		}

		while ( have_posts() )
		{
			the_post();
			
			echo '<li>' . "\n";
			echo '<p><a href="' . apply_filters('the_permalink', get_permalink()) . '" rel="bookmark" title="';
			printf(__('Permanent Link to %s', 'german_newspaper'), the_title_attribute('echo=0'));

			echo '">' . the_title( '', '', false) . '</a></p>' . "\n";
			echo '<small>';
			the_time(__('l, F jS, Y', 'german_newspaper'));
			echo '</small>' . "\n";
			echo '<p class="postmetadata">';
			the_tags(__('Tags: ', 'german_newspaper'), ', ', '<br />');
			echo ' ';
			printf(__('Posted in %s', 'german_newspaper'), get_the_category_list(', '));
			echo '</p>' . "\n" . '</li>' . "\n";
		}

		echo '</li>' . "\n";
		echo '</ul>' . "\n";
	}
	
	echo '<ul>' . "\n";
	
	/* Widgetized sidebar, if you have the plugin installed. */
	if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right_Menu') )
	{
	}

	echo '</ul>' . "\n";
	echo '</div>' . "\n\n";
}





?>